package com.example.clothingmanager.utils;

import org.omg.CORBA.OBJ_ADAPTER;

/**
 * @author Huangyt
 * @version 1.0
 * @date 2020/5/9 8:42
 */
public class Result {
    static private int CODE_SUCCESS = 200;
    static private int CODE_FAIL = 404;
    static private boolean SUCESS = true;
    static private boolean FAIL = false;

    private boolean success;
    private String msg;
    private Object data;
    private int code;

    private Result(boolean success, Object data, String msg, int code) {
        this.success = success;
        this.data = data;
        this.msg = msg;
        this.code = code;
    }

    static public Result success(Object data){
        return new Result(SUCESS, data, "", CODE_SUCCESS);
    }

    static public Result fail(String msg){
        return new Result(FAIL, null, msg, CODE_FAIL);
    }

    static public Result success(){
        return new Result(SUCESS, null, "", CODE_SUCCESS);
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
